<template>
	<u-count-down :time="durition * 1000" autoStart millisecond @change="onChange">
		<view class="timeContent">
			<view class="title">
				距离活动结束还剩
				<text class="days">{{timeData.days}}天</text>
			</view>
			<view class="time">
				<view class="time__custom">
					<text class="time__custom__item">{{ timeData.hours>10?timeData.hours:'0'+timeData.hours}}</text>
				</view>
				<text class="time__doc">:</text>
				<view class="time__custom">
					<text class="time__custom__item">{{ timeData.minutes }}</text>
				</view>
				<text class="time__doc">:</text>
				<view class="time__custom">
					<text class="time__custom__item">{{ timeData.seconds }}</text>
				</view>
			</view>

		</view>
	</u-count-down>
</template>

<script>
	var moment = require('@/utils/moment.js');
	export default {
		name: 'acitivity-countDown',
		data() {
			return {
				timeData: {},
			}
		},
		props: {
			timeEnd: {
				type: String,
				default: ''
			}
		},

		computed: {
			durition() {
				var m1 = moment().format("YYYY-MM-DD HH:mm:ss");
				var m2 = moment(this.timeEnd);
				var diff = m2.diff(m1, 'second');
				return diff
			}
		},
		methods: {
			onChange(e) {
				this.timeData = e
			},
		}
	}
</script>

<style lang="scss">
	.timeContent {
		display: flex;
		flex-direction: column;
		// justify-content: flex-end;
		align-items: flex-end;

		.title {
			font-size: 26upx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: bold;
			text-align: right;
			color: #232323;

			.days {
				font-size: 26upx;
				font-family: PingFang SC, PingFang SC-Bold;
				font-weight: bold;
				text-align: left;
				color: #ec4863;
			}
		}
	}

	.time {

		@include flex;
		align-items: center;
		margin-top: 10upx;

		&__custom {
			margin-top: 4px;
			width: 22px;
			height: 22px;
			background-color: #ebebeb;
			border-radius: 4px;
			/* #ifndef APP-NVUE */
			display: flex;
			/* #endif */
			justify-content: center;
			align-items: center;

			&__item {
				color: #232323;
				font-size: 13px;
				text-align: center;
			}
		}

		&__doc {
			color: #232323;
			padding: 0px 4px;
		}

		&__item {
			color: #606266;
			font-size: 15px;
			margin-right: 4px;
		}
	}
</style>
